#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

const int N=2e5+10;

int mark[N];

int main()
{
	int n,m,ans=0;
	scanf("%d%d",&n,&m);
	while(m--)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		if(a>b) swap(a,b);
		mark[a]++;
		if(mark[a] == 1) ans++;
	}
	
	int q;
	scanf("%d",&q);
	while(q--)
	{
		int op,a,b;
		scanf("%d",&op);
		if(op == 1)
		{
			scanf("%d%d",&a,&b);
			if(a>b) swap(a,b);
			mark[a]++;
			if(mark[a] == 1) ans++;
		}
		else if(op == 2)
		{
			scanf("%d%d",&a,&b);
			if(a>b) swap(a,b);
			mark[a]--;
			if(mark[a] == 0) ans--;
		}
		else 
		{
			printf("%d\n",n-ans);
		}
	}
	return 0;
}
